// pages/collect/collect.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    collect: [],
    tabs: [
      {
        index: 0,
        value: "商品收藏",
        active: true
      },
      {
        index: 1,
        value: "品牌收藏",
        active: false
      },
      {
        index: 2,
        value: "店铺收藏",
        active: false
      },
      {
        index: 3,
        value: "浏览足迹",
        active: false
      },
    ]
  },
  onShow() {
    const collect = wx.getStorageSync("collect")
    this.setData({
      collect
    })
  },
  // 根据标题索引来改变tab
  handleTitleChange(index) {
    let { tabs } = this.data
    tabs.forEach((v, i) => i === index ? v.active = true : v.active = false)
    this.setData({
      tabs
    })
  },
  // 根据tab改变来改变
  tabsIndex(e) {
    const { index } = e.detail
    this.handleTitleChange(index)
  }

  
})